home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / DialogAids.c < prev    next >
Text File  |  1996-06-22  |  16KB  |  683 lines

  1. /* © 1988-91, Bowers Development Corp. */
  2. /* DialogAids.c */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Desk.h>                /* for SystemTask */
  8. #include <Dialogs.h>
  9. #include <Events.h>
  10. #include <Lists.h>
  11. #include <Menus.h>
  12. #include <TextEdit.h>
  13. #include "EventLoop.h"
  14. #include "Globals.h"
  15. #include "ResourceDefs.h"
  16. #include "WindowAids.h"
  17. #include "Windowing.h"
  18. #include "DoScrap.h"
  19.  
  20. #include "DialogAids.h"
  21.  
  22. #include <OSUtils.h>
  23. #include <Packages.h>
  24. #include <ToolUtils.h>
  25. #include "Cursors.h"    /* cursorRgn for WaitNextEvent */
  26.  
  27. #define    gray    0xFFFFFFE8
  28.  
  29. #pragma segment DialogAids
  30.  
  31. /*----------*/
  32. Rect    GetDRect    (short        itemNr)
  33. {
  34.     short        itemType;
  35.     Handle        itemHandle;
  36.     Rect        itemRect;
  37.  
  38.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  39.  
  40.     return (itemRect);
  41. } /*GetDRect*/
  42.  
  43. /*----------*/
  44. static Handle    GetItemHandle    (short        itemNr);
  45. static Handle    GetItemHandle    (short        itemNr)
  46. {
  47.     short        itemType;
  48.     Handle        itemHandle;
  49.     Rect        itemRect;
  50.  
  51.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  52.  
  53.     return (itemHandle);
  54. } /*GetItemHandle*/
  55.  
  56. /*----------*/
  57. pascal void LineItem    (DialogPtr        dialog,
  58.                          short            itemNr)
  59. {
  60. #pragma unused (dialog)
  61.  
  62.     PenState        savePen;
  63.     Rect            itemRect;
  64.  
  65.     GetPenState (&savePen);
  66.     PenNormal ();
  67.     /*PenPat (&qd.gray);*/
  68.     PenPat ((PatPtr)gray);
  69.     itemRect = GetDRect (itemNr);
  70.     MoveTo (itemRect.left, itemRect.top);
  71.     LineTo (itemRect.right - 1, itemRect.bottom - 1);
  72.     SetPenState (&savePen);
  73. } /*LineItem*/
  74.  
  75. /*----------*/
  76. pascal void RectItem    (DialogPtr        dialog,
  77.                          short            itemNr)
  78. {
  79. #pragma unused (dialog)
  80.  
  81.     Rect            itemRect;
  82.     PenState        savePen;
  83.  
  84.     GetPenState (&savePen);
  85.     PenNormal ();
  86.     itemRect = GetDRect (itemNr);
  87.     FrameRect (&itemRect);
  88.     SetPenState (&savePen);
  89. } /*RectItem*/
  90.  
  91. /*----------*/
  92. void SetUserItem    (short        itemNr,
  93.                      ProcPtr    doDraw)
  94. {
  95.     short            itemType;
  96.     Handle            itemHandle;
  97.     Rect            itemRect;
  98.  
  99.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  100.     SetDItem (qd.thePort, itemNr, itemType, (Handle) doDraw, &itemRect);
  101. } /*SetUserItem*/
  102.  
  103. /*----------*/
  104. void OutlineButton    (short        itemNr)
  105. {
  106.     Rect            itemRect;
  107.     PenState        savePen;
  108.  
  109.     GetPenState (&savePen);
  110.     PenNormal ();
  111.     PenSize (3, 3);
  112.     itemRect = GetDRect (itemNr);
  113.     InsetRect (&itemRect, -4, -4);
  114.     FrameRoundRect (&itemRect, 16, 16);
  115.     SetPenState (&savePen);
  116. } /*OutlineButton*/
  117.  
  118. /*----------*/
  119. void EnableDItem    (short        itemNr,
  120.                      Boolean    enable)
  121. {
  122.     short            itemType;
  123.     Handle            itemHandle;
  124.     Rect            itemRect;
  125.     ControlHandle    control;
  126.  
  127.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  128.     if (enable) {
  129.         itemType &= ~itemDisable;
  130.     } else {
  131.         itemType |= itemDisable;
  132.     }
  133.     SetDItem (qd.thePort, itemNr, itemType, itemHandle, &itemRect);
  134.  
  135.     if ((itemType & ctrlItem) != 0) {        /* it's a control */
  136.         control = (ControlHandle) itemHandle;
  137.         HiliteScroll (control, enable);
  138.     } /*else … do nothing?*/
  139. } /*EnableDItem*/
  140.  
  141. /*----------*/
  142. void SetDText        (short        itemNr,
  143.                      Str255        text)
  144. {
  145.     Handle            itemHandle;
  146.  
  147.     itemHandle = GetItemHandle (itemNr);
  148.     SetIText (itemHandle, text);
  149. } /*SetDText*/
  150.  
  151. /*----------*/
  152. void GetDText        (short        itemNr,
  153.                      Str255        text)
  154. {
  155.     Handle            itemHandle;
  156.  
  157.     itemHandle = GetItemHandle (itemNr);
  158.     GetIText (itemHandle, text);
  159. } /*GetDText*/
  160.  
  161. /*----------*/
  162. void SetDNum        (short        itemNr,
  163.                      long        num)
  164. {
  165.     Str255            text;
  166.  
  167.     NumToString (num, text);
  168.     SetDText (itemNr, text);
  169. } /*SetDNum*/
  170.  
  171. /*----------*/
  172. void GetDNum        (short        itemNr,
  173.                      long        *num)
  174. {
  175.     Str255            text;
  176.  
  177.     GetDText (itemNr, text);
  178.     StringToNum (text, num);
  179. } /*GetDNum*/
  180.  
  181. /*----------*/
  182. void SetCheckbox    (short        itemNr,
  183.                      Boolean    checked)
  184. {
  185.     ControlHandle    control;
  186.  
  187.     control = (ControlHandle) GetItemHandle (itemNr);
  188.     SetCtlMax (control, 1);
  189.     SetCtlValue (control, checked);
  190. } /*SetCheckbox*/
  191.  
  192. /*----------*/
  193. void DoCheckbox        (short        itemNr,
  194.                      Boolean    *checked)
  195. {
  196.     *checked = !*checked;
  197.     SetCheckbox (itemNr, *checked);
  198. } /*DoCheckbox*/
  199.  
  200. /*----------*/
  201. void SetRadio        (short        firstItem,
  202.                      short        choice)
  203. {
  204.     SetCheckbox (firstItem + (choice - 1), true); 
  205. } /*SetRadio*/
  206.  
  207. /*----------*/
  208. void DoRadio        (short        firstItem,
  209.                      short        itemNr,
  210.                      short        *choice)
  211. {
  212.     SetCheckbox (firstItem + (*choice - 1), false);
  213.     *choice = itemNr - firstItem + 1;
  214.     SetCheckbox (firstItem + (*choice - 1), true); 
  215. } /*DoRadio*/
  216.  
  217. /*----------*/
  218. static void InvertIcon        (short        itemNr);
  219. static void InvertIcon        (short        itemNr)
  220. {
  221.     Rect            itemRect;
  222.  
  223.     itemRect = GetDRect (itemNr);
  224.     InsetRect (&itemRect, 1, 1);
  225.     InvertRect (&itemRect);
  226. } /*InvertIcon*/
  227.  
  228. /*----------*/
  229. void DoIconRadio    (short        firstIcon,
  230.                      short        itemNr,
  231.                      short        *choice)
  232. {
  233.     InvertIcon (firstIcon + (*choice - 1));
  234.     *choice = (itemNr - firstIcon) + 1;
  235.     InvertIcon (firstIcon + (*choice - 1));
  236. } /*DoIconRadio*/
  237.  
  238. /*----------*/
  239. void SetCtlChoice    (short        itemNr,
  240.                      short        choice)
  241. {
  242.     ControlHandle    control;
  243.  
  244.     control = (ControlHandle) GetItemHandle (itemNr);
  245.     SetCtlValue (control, choice);
  246. } /*SetCtlChoice*/
  247.  
  248. /*----------*/
  249. short GetCtlChoice    (short        itemNr)
  250. {
  251.     ControlHandle    control;
  252.  
  253.     control = (ControlHandle) GetItemHandle (itemNr);
  254.     return (GetCtlValue (control));
  255. } /*GetCtlChoice*/
  256.  
  257. /*----------*/
  258. void DoPalette        (short        itemNr,
  259.                      short        *choice)
  260. {
  261.     *choice = GetCtlChoice (itemNr);
  262. } /*DoPalette*/
  263.  
  264. /*----------*/
  265. void DoMultiState    (short         itemNr,
  266.                      short        *value)
  267. {
  268.     ControlHandle    control;
  269.  
  270.     control = (ControlHandle) GetItemHandle (itemNr);
  271.     if (*value == GetCtlMax (control)) {
  272.         *value = GetCtlMin (control);
  273.     } else {
  274.         *value += 1;
  275.     }
  276.     SetCtlValue (control, *value);
  277. } /*DoMultiState*/
  278.  
  279. /*----------*/
  280. void SetScrollItem  (short        itemNr,
  281.                      short        value,
  282.                      short        min,
  283.                      short        max,
  284.                      short        pageSize)
  285. {
  286.     ControlHandle    scroll;
  287.  
  288.     scroll = (ControlHandle) GetItemHandle (itemNr);
  289.     SetCtlMin     (scroll, min);
  290.     SetCtlMax     (scroll, max);
  291.     SetCtlValue     (scroll, value);
  292.     SetCRefCon     (scroll, pageSize);
  293.     HiliteScroll (scroll, (min < max));
  294. } /*SetScrollItem*/
  295.  
  296. /*----------*/
  297. void DoScrollItem    (short        itemNr,
  298.                      short        *value)
  299. {
  300.     ControlHandle    scroll;
  301.  
  302.     scroll = (ControlHandle) GetItemHandle (itemNr);
  303.     *value = GetCtlValue (scroll);
  304. } /*DoScrollItem*/
  305.  
  306. /*----------*/
  307. void DrawPopup        (short        itemNr,
  308.                      short        menuID,
  309.                      short        choice)
  310. {
  311.     Rect            itemRect;
  312.  
  313.     itemRect = GetDRect (itemNr);
  314.     UpdatePopup (itemRect, menuID, choice);
  315. } /*DrawPopup*/
  316.  
  317. /*----------*/
  318. void DoPopup        (short        itemNr,
  319.                      short        menuID,
  320.                      short        *choice)
  321. {
  322.     Rect            itemRect;
  323.  
  324.     itemRect = GetDRect (itemNr);
  325.     TrackPopup (itemRect, menuID, choice);
  326. } /*DoPopup*/
  327.  
  328. /*----------*/
  329. void InvertLabel    (short        itemNr)
  330. {
  331.     Rect            itemRect;
  332.  
  333.     itemRect = GetDRect (itemNr);
  334.     InvertRect (&itemRect);
  335. } /*InvertLabel*/
  336.  
  337. /*----------*/
  338. ListHandle  Vert1List    (short        itemNr)
  339. {
  340.     Rect            itemRect;
  341.     ListHandle        list;
  342.  
  343.     itemRect = GetDRect (itemNr);
  344.     list = NewV1List (itemRect, qd.thePort);
  345.  
  346.     return (list);
  347. } /*Vert1List*/
  348.  
  349. /*----------*/
  350. Boolean FilterList    (EventRecord    *event,
  351.                      ListHandle        list,
  352.                      short            listItem,
  353.                      short            dblClickItem,
  354.                      short            *itemHit)
  355. {
  356.     Boolean            filtered;
  357.     Point            mousePos;
  358.  
  359.     filtered = false;
  360.     if ((*event).what == mouseDown) {
  361.         mousePos = (*event).where;
  362.         GlobalToLocal (&mousePos);
  363.         if (FindDItem (qd.thePort, mousePos) + 1 == listItem) {
  364.             if (LClick (mousePos, (*event).modifiers, list)) {
  365.                 *itemHit = dblClickItem;
  366.             } else {
  367.                 *itemHit = listItem;
  368.             }
  369.             filtered = true;
  370.         }
  371.     }
  372.     return (filtered);
  373. } /*FilterList*/
  374.  
  375. /*----------*/
  376. Boolean FilterScroll    (EventRecord    *event,
  377.                          short            scrollItem,
  378.                          ScrollProcPtr    actionProc,
  379.                          short            *itemHit)
  380. {
  381.     Boolean            filtered;
  382.     Point            mousePos;
  383.     short            partCode;
  384.     ControlHandle    whichControl;
  385.  
  386.     filtered = false;
  387.     if ((*event).what == mouseDown) {
  388.         mousePos = (*event).where;
  389.         GlobalToLocal (&mousePos);
  390.         if (FindDItem (qd.thePort, mousePos) + 1 == scrollItem) {
  391.             partCode = FindControl (mousePos, qd.thePort, &whichControl);
  392.             if (partCode != 0) {
  393.                 TrackScroll (whichControl, partCode, mousePos, actionProc);
  394.                 *itemHit = scrollItem;
  395.                 filtered = true;
  396.             }
  397.         }
  398.     }
  399.     return (filtered);
  400. } /*FilterScroll*/
  401.  
  402. /*----------*/
  403. void FilterIcon        (EventRecord    *event,
  404.                      short            firstIcon,
  405.                      short            choice)
  406. {
  407.     short            itemType;
  408.     Handle            itemHandle;
  409.     Rect            itemRect;
  410.  
  411.     if (((*event).what == updateEvt)
  412.     &&  ((WindowPtr) (*event).message == qd.thePort)) {
  413.         GetDItem (qd.thePort, firstIcon + (choice - 1), &itemType, &itemHandle, &itemRect);
  414.         PlotIcon (&itemRect, itemHandle);
  415.         ValidRect (&itemRect);
  416.         InsetRect (&itemRect, 1, 1);
  417.         InvertRect (&itemRect);
  418.     }
  419. } /*FilterIcon*/
  420.  
  421. /*----------*/
  422. pascal Boolean StandardFilter    (DialogPtr        whichDialog,
  423.                                  EventRecord    *event,
  424.                                  short            *itemHit)
  425. {
  426.     #define returnKey        13
  427.     #define enter            3
  428.     #define esc                27
  429.     #define pushButton        (ctrlItem + btnCtrl)
  430.     
  431.     Boolean            filtered;
  432.     DialogPeek        whichPeek;
  433.     short            defItem;    /*    aDefItem: default button item number    */
  434.     char            key;
  435.     short            itemType;
  436.     Handle            itemHandle;
  437.     Rect            itemRect;
  438.     long            finalTicks;
  439.  
  440.     filtered = false;
  441.     whichPeek = (DialogPeek) whichDialog;
  442.     defItem = whichPeek->aDefItem;
  443.     switch ((*event).what) {
  444.     case keyDown:
  445.     case autoKey:
  446.         key = (*event).message & charCodeMask;
  447.         if ((key == returnKey) || (key == enter) || (key == esc)
  448.         || ((key == '.') && (((*event).modifiers & cmdKey) != 0))) {
  449.             if ((key == returnKey) || (key == enter)) {
  450.                 *itemHit = defItem;
  451.             } else {
  452.                 *itemHit = cancel;
  453.             }
  454.             GetDItem (whichDialog, *itemHit, &itemType, &itemHandle, &itemRect);
  455.             if ((itemType & itemDisable) == 0) {
  456.                 if ((itemType & (255 - itemDisable)) == pushButton) {
  457.                     HiliteControl ((ControlHandle) itemHandle, inButton);
  458.                     #ifdef fast
  459.                     #else
  460.                         Delay (8, &finalTicks);
  461.                     #endif
  462.                     HiliteControl ((ControlHandle) itemHandle, 0);
  463.                 }
  464.                 filtered = true;
  465.             } /*if*/
  466.         } else {
  467.             if ((((*event).modifiers & cmdKey) != 0)
  468.             &&  ((key == 'x') || (key == 'c') || (key == 'v'))) {
  469.                 *itemHit = (whichPeek)->editField + 1;
  470.                 switch (key) {
  471.                 case 'x':
  472.                         DlgCut (whichDialog);
  473.                         scrapDirty = (*itemHit > 0);
  474.                     break;
  475.                 case 'c':
  476.                         DlgCopy (whichDialog);
  477.                         scrapDirty = (*itemHit > 0);
  478.                         *itemHit = 0;
  479.                     break;
  480.                 case 'v':
  481.                         DlgPaste (whichDialog);
  482.                     break;
  483.                 } /*switch*/
  484.                 if (*itemHit > 0) {
  485.                     GetDItem (whichDialog, *itemHit, &itemType, &itemHandle, &itemRect);
  486.                     if ((itemType & itemDisable) == 0) {
  487.                         filtered = true;
  488.                     }
  489.                 }
  490.                 if (!filtered) {
  491.                     (*event).what = nullEvent;
  492.                 }
  493.             }
  494.         }
  495.         break;
  496.     case updateEvt:
  497.         if ((WindowPtr) (*event).message == qd.thePort) {
  498.             GetDItem (whichDialog, defItem, &itemType, &itemHandle, &itemRect);
  499.             if ((itemType & (255 - itemDisable)) == pushButton) {
  500.                 OutlineButton (defItem);
  501.             }
  502.         } else if (!IsDialogEvent (event)) {
  503.             curEvent = *event;
  504.             DoUpdate (curEvent);    /* update other windows *//*    EventLoop.c    */
  505.         }
  506.         break;
  507.     } /*switch*/
  508.     return (filtered);
  509. } /*StandardFilter*/
  510.  
  511. /*----------*/
  512. /* This procedure is called by DoModalEvent to handle a mouseDown in a */
  513. /* movable modal dialog. */
  514. /*----------*/
  515. static void    DoMouseDown (void);
  516. static void    DoMouseDown (void)
  517. {
  518.     long            menuChoice;
  519.     short            menuID;
  520.     short            itemNr;
  521.     WindowPtr        whichWindow;
  522.     short            whichPart;
  523.  
  524.     whichPart = FindWindow (curEvent.where, &whichWindow);
  525.     switch (whichPart) {
  526.         case inMenuBar:
  527.                 menuChoice = MenuSelect (curEvent.where);
  528.                 menuID = HiWord (menuChoice);
  529.                 itemNr = LoWord (menuChoice);
  530.                 if ((menuID != 0) && (itemNr != 0)) {
  531. /*Need to handle Cut, Copy, Paste here just like StandardFilter does.*/
  532.                     SysBeep (1);
  533.                 }    /* otherwise, MenuSelect returned 0. Either the user    */
  534.                     /* chose nothing, or the user chose from a System        */
  535.                     /* menu, and it's been taken care of                    */
  536.             break;
  537.         case inDrag:
  538.                 if (whichWindow == FrontWindow ()) {
  539.                     DoDrag (whichWindow);            /*permit drag of this dialog*/
  540.                 } else {
  541.                     SysBeep (1);                    /*can't drag any other window*/
  542.                 }
  543.             break;
  544.         case inSysWindow:
  545.         case inContent:
  546.         case inDesk:
  547.         case inGrow:
  548.         case inGoAway:
  549.         case inZoomIn:
  550.         case inZoomOut:
  551.         default:
  552.                 SysBeep (1);
  553.             break;
  554.     } /*case*/
  555. } /*DoMouseDown*/
  556.  
  557. /*----------*/
  558. static Boolean        sFiltered;            /*used by DoModalEvent & MovableDialog*/
  559.  
  560. /*----------*/
  561. static Boolean GetEvent    (void);
  562. static Boolean GetEvent    ()
  563. {
  564.     Boolean            gotEvent;
  565.  
  566.     if (sysConfig.hasWNE) {
  567.         gotEvent = WaitNextEvent (everyEvent, &curEvent, 0L, cursorRgn);
  568.     } else {
  569.         SystemTask ();
  570.         gotEvent = GetNextEvent (everyEvent, &curEvent);
  571.     }
  572.     return (gotEvent);
  573. } /*GetEvent*/
  574.  
  575. /*----------*/
  576. /* This function processes the next modal dialog event and then returns. It is called        */
  577. /* by MovableDialog, but it can also be called directly. Assumes that the frontmost            */
  578. /* window is a modal (or movable modal) dialog window.                                        */
  579. /*                                                                                            */
  580. /* If the event is associated with an item in the current dialog, returns the item number.    */
  581. /* If filterProc (or System 7.0's standard filter, or DialogSelect) handled the event        */
  582. /* (and presumably set itemHit); sets sFiltered to true, otherwise sets sFiltered to false.    */
  583. /* If the event is not associated with an item in the current dialog, returns 0.            */
  584. /*----------*/
  585. short    DoModalEvent    (ModalFilterProcPtr        filterProc)
  586. {
  587.     WindowPtr        eventWindow;
  588.     short            itemHit;        /*function return value*/
  589.     GrafPtr            savePort;
  590.     DialogPtr        theDialog;
  591.  
  592.     GetPort(&savePort);
  593.  
  594.     sFiltered = false;
  595.     itemHit = 0;
  596.     theDialog = FrontWindow ();
  597.     if (GetEvent () || (curEvent.what == nullEvent)) {
  598.                                 /*got an event to process*/
  599.         if (curEvent.what == app4Evt) {
  600.           /* here so event won't get swallowed by IsDialogEvent */
  601.           /* and so suspend/resume can be translated to deactivate/activate */
  602.             DoApp4Event ();
  603.         }
  604.         if (IsDialogEvent (&curEvent)) {
  605.                                     /*it's a dialog event*/
  606.             if ((curEvent.what == activateEvt) || (curEvent.what == updateEvt)) {
  607.                 eventWindow = (DialogPtr) curEvent.message;
  608.             } else {
  609.                 eventWindow = FrontWindow ();
  610.             }
  611.             SetPort (eventWindow);
  612.             if (filterProc != NULL) {
  613.                                 /*caller passed a filterProc*/
  614.                 sFiltered = (*filterProc) (theDialog, &curEvent, &itemHit);
  615.             } else {
  616.                                 /*filterProc == NULL*/
  617. /* Need to do if (gestalt then if gestalt(stdfilter available)) sFiltered = stdfilter ()    */
  618. /* See Tech Note #304 p. 4 for GetStdFilterProc                                                */
  619.                 sFiltered = StandardFilter (theDialog, &curEvent, &itemHit);
  620.             }
  621.             if (!sFiltered) {
  622.                     /*either filterProc == NULL, or filterProc
  623.                      didn't process curEvent (although filterProc
  624.                      may have altered curEvent)*/
  625. /*Don't need to handle Cmd-keys here, since StandardFilter does.*/
  626.                 sFiltered = DialogSelect (&curEvent, &theDialog, &itemHit);
  627.             } /*otherwise, sFiltered*/
  628.         } else {                /*it's not a dialog event*/
  629.             switch (curEvent.what) {
  630.                 case mouseDown:
  631.                         DoMouseDown ();
  632.                     break;
  633.                 case mouseUp:
  634.                 case keyDown:
  635.                 case autoKey:
  636.                                     /*do nothing*/
  637.                     break;
  638.                 case updateEvt:
  639.                         DoUpdate (curEvent);
  640.                     break;
  641.                 case activateEvt:
  642.                                     /*do nothing, to avoid setting cur to noCur*/
  643.                     break;
  644.                 case diskEvt:
  645.                         DoDiskEvent ();
  646.                     break;
  647.                 default:
  648.                         /*Do nothing*/
  649.                     break;
  650.             } /*case*/
  651.         } /*if dialog event or not*/
  652.     } /*otherwise, not GetEvent and curEvent.what != nullEvent*/
  653.  
  654.     SetPort(savePort);
  655.  
  656.     return (itemHit);
  657. } /*DoModalEvent*/
  658.  
  659. /*----------*/
  660. /* This procedure works just like ModalDialog, case plus:                            */
  661. /*    - clicking and dragging in the dialog's title bar will move the dialog            */
  662. /*    - application windows update                                                    */
  663. /*    - under System 7.0, uses the same standard filter proc as ModalDialog            */
  664. /* Under System 7.0, the dialog window's procID should be movableDBoxProc            */
  665. /* (== 5, from Windows.p).                                                            */
  666. /* Under System 6.x, procID movableDBoxProc is equivalent to dBoxProc, and the        */
  667. /* user won't be able to drag the dialog. However, if the procID is noGrowDocProc,    */
  668. /* then the user will be able to drag the dialog.                                    */
  669. /* Modifies global curEvent (Globals.p).                                            */
  670. /*----------*/
  671. void    MovableDialog    (ModalFilterProcPtr        filterProc,
  672.                          short                    *itemHit)
  673. {
  674. /*Need to disable all of application's menus except Cut/Copy/Paste here*/
  675.     *itemHit = 0;
  676.     if (FrontWindow () != NULL) {
  677.         sFiltered = false;
  678.         while (!sFiltered) {
  679.             *itemHit = DoModalEvent (filterProc);        /*also sets sFiltered*/
  680.         } /*while not sFiltered*/
  681.     } /*otherwise, no front window*/
  682. } /*MovableDialog*/
  683.